package com.example.huadi1.controller;

import com.example.huadi1.dto.Registration;
import com.example.huadi1.service.RegistrationService;
import com.example.huadi1.utils.AjaxResult;
import com.example.huadi1.utils.msg.AcceptJson;
import com.example.huadi1.utils.msg.RegistrationJson;
import org.aspectj.weaver.loadtime.Aj;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@SuppressWarnings({"unchecked", ""})
@RequestMapping("/regis")
//@Controller
//@ResponseBody
@RestController
public class RegistrationController {

    @Autowired
    private RegistrationService registrationService;
//    分页获取全部学生，传递参数两个private Integer pageNum;
//    private Integer pageSize;
    @PostMapping("/all")
    public AjaxResult allRegis(@RequestBody RegistrationJson registrationJson){
        return registrationService.allRegis(registrationJson);
    }
//    根据id查询学生，传递参数一个private Integer stu_ID;
    @PostMapping("/id")
    public AjaxResult findById(@RequestBody AcceptJson acceptJson){
        Registration registration =  registrationService.findById(acceptJson.stu_ID);
        if(registration==null) return AjaxResult.error();
        return AjaxResult.success(registration);
    }
//    添加学生
    @PostMapping("/add")
    public AjaxResult addRegis(@RequestBody Registration registration ){
        return registrationService.addRegis(registration);
    }
//    线下缴费,传递参数任选一个private Integer tution_method;
//    private Integer agency_fee_method;
//    private Integer hotel_expense_method;
    @PostMapping("/offline")
    public AjaxResult updateOffline(@RequestBody Registration registration ){
        return registrationService.updateOffline(registration);
    }
//    线上缴费，传递参数任选一个private Integer tution_method;
//    private Integer agency_fee_method;
//    private Integer hotel_expense_method;
    @PostMapping("/online")
    public AjaxResult updateOnine(@RequestBody Registration registration ){
        return registrationService.updateOnline(registration);
    }
//    绿色通道，传递参数一个private Integer green_channel;
    @PostMapping("/green")
    public AjaxResult GreenChannel(@RequestBody AcceptJson acceptJson){
        return registrationService.GreenChannel(acceptJson.stu_ID);
    }
//    测试
    @RequestMapping("/game")
    @ResponseBody
    public Object info(){
        return "this is info";
    }
//    绿色通道报表
    @PostMapping("/form/green")
    public AjaxResult greenChannelForm(@RequestBody RegistrationJson registrationJson){
        return registrationService.greenChannelForm(registrationJson);
    }
//    现场缴费报表
    @PostMapping("/form/offline")
    public AjaxResult offlineForm(@RequestBody RegistrationJson registrationJson){
        return registrationService.offlineForm(registrationJson);
    }
//    网上缴费报表
    @PostMapping("/form/online")
    public AjaxResult onlineForm(@RequestBody RegistrationJson registrationJson){
        return registrationService.onlineForm(registrationJson);
    }
//    综合报表
    @PostMapping("/form/sum")
    public AjaxResult sumForm(@RequestBody RegistrationJson registrationJson){
        return registrationService.sumForm(registrationJson);
    }
//    报到报表
    @PostMapping("/form/regis")
    public AjaxResult registrationForm(@RequestBody RegistrationJson registrationJson){
        return registrationService.registrationForm(registrationJson);
    }

}
